import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import GaiKuang from '../views/GaiKuang.vue'
import ZhuanYe from '../views/ZhuanYe.vue'
import More from '../views/More.vue'

Vue.use(VueRouter)

const routes = [
	{
		path: '/',
		name: 'Home',
		component: Home,
		children: [
			{
				path: '/',
				component: GaiKuang
			},
			{
				path: 'zhuanye',
				component: ZhuanYe
			},
			{
				path: 'more',
				component: More
			}
		]
	}
]

const router = new VueRouter({
	routes
})

router.beforeEach((to, from, next) => {
	if (window._cancel) {
		window._cancel.forEach((item, index) => {
			item.cancel("中断请求");
			delete window._cancel[index];
		})
	}
	next();
})

export default router
